<script type="text/javascript" src="<?=base_url()?>resource/js/layer/layer.js"></script>
<script type="application/javascript" src="<?=base_url().'resource/js/jquery.PrintArea.js'?>" ></script>
<script src="<?=base_url()?>resource/js/uploadPreview.min.js" type="text/javascript"></script>
<script type="application/javascript">
    function myform_submit() {
        //拆包质检是否合格
        <?php if($orderFirst['service_type']==2 || $orderFirst['service_type']==5): ?>
        var isUnpackPass = $("input[name='isUnpackPass']:checked").val();
        if(!isUnpackPass){
            alert('<?=lang('product_qxzsfhg')?>');
            return false;
        }
        <?php endif;?>
        //输入运费
        <?php if($isInFreight):?>
        var shippingFee = $("input[name='shippingFeeText']").val();
        if(!shippingFee){
            $('#shippingFeeTextId').focus();
            alert('shipping Fee not empty');
            return false;
        }
        <?php endif;?>

        //是否质保
        var inWarranty_qc = $("input[name='inWarranty_qc']:checked").val();
        if(!inWarranty_qc){
            alert('<?=lang('product_qxzsfzb')?>');
            return false;
        }else{
            if(inWarranty_qc==0 && inWarranty_qc!="<?=$productFirst['inWarranty_qc']?>"){
                var warranty_img_1=$("input[name='warranty_img_1']").val();
                var warranty_img_2=$("input[name='warranty_img_2']").val();
                var warranty_img_3=$("input[name='warranty_img_3']").val();
                var warranty_remark_qc=$("textarea[name='warranty_remark_qc']").val();
                if(warranty_img_1=='' && warranty_img_2=='' && warranty_img_3==''){
                    alert('<?=lang('product_qscbwtp')?>');
                    return false;
                }
                if(warranty_remark_qc==''){
                    alert('<?=lang('product_qxzbwbz')?>');
                    return false;
                }
            }
        }
        //描述是否一致
        var descriptionConsistent = $("input[name='descriptionConsistent']:checked").val();
        if(!descriptionConsistent){
            alert('<?=lang('product_qxzmssfxf')?>');
            return false;
        }
        //成色
        var physicalAppearance = $("input[name='physicalAppearance']:checked").val();
        if(!physicalAppearance){
            alert('<?=lang('product_qxzwgcs')?>');
            return false;
        }
        //附件
        var accessories = $("#accessoriesDivId :checkbox:checked");
        if(accessories.length<=0){
            alert('<?=lang('product_qxzfj')?>');
            return false;
        }
        //故障
        var fault = $("#faultDivId :checkbox:checked");
        if(fault.length<=0){
            alert('<?=lang('product_qxzgz')?>');
            return false;
        }
        return true;
    }
    /*//环球提示信息跳转
    function hqUrl(){
        window.location.href='<?=blang_url('products/Product_new/inDetails/'.$productFirst['id'])?>';
    }
    *//**
     * 环球易购信息同步
     * @constructor
     *//*
    function GlobalEGrowSync(){
        $.post("<?=blang_url('ajax/ajax/GlobalEGrowSync')?>",{'pid':<?=$productFirst['id']?>,'RepairInfo':1},function(data){
            if(data=='101'){
                $('#hqMsg').html("<span style='color: #ff0000'>失败(环球易购通信故障)</span>");
            }else{
                var object=JSON.parse(data);
                if(object['RepairInfo']['code']===0){
                    $('#hqMsg').html("<span style='color: #00ee00'>成功!</span>");
                }else{
                    $('#hqMsg').html("<span style='color: #ff0000'>失败("+object['msg']+")</span>");
                }
            }
        });
    }*/
</script>
<script type="application/javascript">
    $(function() {
        $("input#printPidBut").click(function () {
            $("div#myPrintArea").printArea();
        });
        $('#orderManageForm').form({
            onSubmit:function(){
                if(myform_submit()){
                    $.ajax({
                        type: "POST",
                        url:"<?=blang_url('products/Product_new/'.$post_type)?>",
                        data: $('#orderManageForm').serialize()+"&submits=tijiao",
                        success: function (data) {
                            /*if(<?=$orderFirst['merchant_num']?>==428) {
                                layer.open({
                                    type: 1,
                                    shade: [0.1, '#393D49'],
                                    title: false, //不显示标题
                                    content: $('#hqDIV'),
                                    cancel: function () {
                                        window.location.href = '<?=blang_url('products/Product_new/inDetails/'.$productFirst['id'])?>';
                                    }
                                });
                                GlobalEGrowSync();
                            }else{*/
                                $.messager.alert('系统提示信息', "拆包质检完成", 'info',function(){
                                    window.location.href='<?=blang_url('products/Product_new/inDetails/'.$productFirst['id'])?>';
                                });
                            /*}*/
                        },
                        error: function(data) {
                            $.messager.alert('系统提示信息', "提交失败", 'error');
                        }
                    });
                }
                return false;
            }
        });
    });
</script>
</head>
<body>
<style type="text/css">
    #myPrintArea {
        height: 30mm;
        width: 50mm;
        overflow: hidden;
        line-height: 0;
        display: none;
        padding:0;

    }

    .addInputStyle tr td label {
        width: auto;
        margin-right: 15px;;
        margin-bottom: 7px;
    }
    .layer_notice {
        float: left;
        height: 75px;
        width: 330px;
        background: #F1EFF4;
        overflow: hidden;
        padding: 10px;
    }
</style>
<div id="myPrintArea" style="font-size: 8px;padding:0;height:29.9mm;width:50mm;overflow:hidden;color:#000; font-family:Arial;line-height: 17px;">
    <div style="text-align: center;"><strong style="font-size: 19px;"><?= $productFirst['order_num'] ?></strong></div>
    <div class="print_content" style="margin:auto;height: 5mm;overflow: hidden;padding:0;width:100%;">
        <center><?= $tt_barcode ?></center>
    </div>
    <div style="text-align: center;font-size:8px;padding:0;margin:0;clear:both;width:49.9mm;">

        T:<strong style="font-size: 19px;"><?= $productFirst['serviceTypeName'] ?></strong>
        S:<?= $orderFirst['storeOrShip'] ? 'Sipping' : 'Storage' ?>
        P:<strong style="font-size: 19px;"><?= $productFirst['id'] ?></strong>
        </div>
    <div style="text-align: center;font-size:8px;padding:0;margin:0;height:10mm;width:49mm; overflow: hidden">
        <strong style="font-size: 19px;"><?= $productFirst['product_brand'] ?> </strong> / <strong style="font-size: 19px;"><?= $productFirst['product_model'] ?></strong>

    </div>
    <div><center>[<?= mb_substr($merchant['name_en'],0,21,'utf-8') ?>]</center></div>
</div>

<!--菜单 start-->
<?php $this->load->view('defaults/common/left');?>
<!--菜单 end-->
<div id="content">
    <div class="page-header">
        <div class="container-fluid">
        <h1><?=lang('order_cbzj')?></h1>
        <?=$this->breadcrumb->generateHTML();?>
        </div>
    </div>
    <div class="container-fluid">
        <div class="panel panel-default">
            <div class="panel-heading">
                <h3 class="panel-title"><i class="fa fa-pencil"></i><?=lang('order_cbzj')?></h3>
            </div>
            <div class="panel-body">
                <div class="table-responsive">
                    <table class="style20170608" cellspacing="0">
                      <tbody>
                        <tr>
                            <td class="tableSubtitle odd"><?=lang('order_wxdh')?></td>
                            <td class="tableContent"><?=$productFirst['order_num']?><input class=" btn btn-oms btn-sm" style="margin-left:5px;" id="printPidBut" type="button" value="print" /></td>                                               
                            <td class="tableSubtitle odd"><?=lang('order_wxlx')?></td>
                            <td class="tableContent"><?=$productFirst['serviceTypeName']?></td>
                        </tr>
                        <tr>
                            <td class="tableSubtitle even"><?=lang('order_lydh')?></td>
                            <td class="tableContent"><?=$productFirst['source_id_order']?></td>                                                            
                            <td class="tableSubtitle even"><?=lang('product_cplx')?></td>
                            <td class="tableContent"><?=$productFirst['category_name']?></td>
                        </tr>
                        <tr>
                            <td class="tableSubtitle odd">SKU</td>
                            <td class="tableContent"><?=$productFirst['productSku']?></td>                                                            
                            <td class="tableSubtitle odd">IMEI</td>
                            <td class="tableContent"><?=$productFirst['imei']?></td>
                        </tr>
                        <tr>
                            <td class="tableSubtitle even">brand</td>
                            <td class="tableContent"><?=$productFirst['product_brand']?></td>                                                            
                            <td class="tableSubtitle even">model</td>
                            <td class="tableContent"><?=$productFirst['product_model']?></td>
                        </tr>
                        <tr>
                            <td class="tableSubtitle odd"><?=lang('order_zt')?></td>
                            <td class="tableContent"><?=$productFirst['statusName']?></td>
                            <td class="tableSubtitle odd"><?=lang('product_ppkhbh')?></td>
                            <td class="tableContent"><?=$brandCustomer['id']?></td>                                                           
                        </tr>
                         <tr>
                            <td class="tableSubtitle even"><?=lang('product_ppkhmc')?></td>
                            <td class="tableContent"><?=$brandCustomer['name']?></td> 
                            <td class="tableSubtitle even"><?=lang('product_gzms')?></td>
                            <td class="tableContent"><?=$productFirst['defectDes']?></td>                                                                   
                        </tr>
                        <tr>
                            <td class="tableSubtitle odd"><?=lang('product_khbz')?></td>
                            <td class="tableContent" colspan="3">
                             <?=$productFirst['customerRemark']?>
                            </td>                                                         
                        </tr>
                        <tr>
                            <td class="tableSubtitle even">hint</td>
                            <td class="tableContent" colspan="3"><?=$productFirst['inWarranty_trName']?></td>
                        </tr>
                      </tbody>
                    </table>
                    
                    <div id="contents_container" style="margin-top: 10px;overflow: hidden;">
                        <form class="form-horizontal" action="" method="post" name="myform"  autocomplete="off" id="orderManageForm" enctype="multipart/form-data" >
                            <div class="form-group">
                                <label class="col-sm-2 control-label"><?=lang('product_cpzt')?></label>
                                <div class="col-sm-10">
                                    <label class="oms-radio">
                                        <input type="radio" name="available" value="0" <?=$ckdAvailable['0']?> />delete
                                    </label>
                                    <label class="oms-radio">
                                        <input type="radio" name="available" value="1" <?=$ckdAvailable['1']?> />normal
                                    </label>
                                    <label class="oms-radio">
                                       <input type="radio" name="available" value="2" <?=$ckdAvailable['2']?>/>hold
                                    </label>
                                </div>
                            </div>
                            <?php if($orderFirst['service_type']==2 || $orderFirst['service_type']==5): ?>
                            <div class="form-group">
                                <label class="col-sm-2 control-label"><?=lang('product_cbsfhg')?></label>
                                <div class="col-sm-10">
                                    <label class="oms-radio">
                                        <input type="radio" name="isUnpackPass" value="0"  <?=$ckdIsUnpackPass['0']?>/>No
                                    </label>
                                    <label class="oms-radio">
                                        <input type="radio" name="isUnpackPass" value="1"  <?=$ckdIsUnpackPass['1']?>/>Yes
                                    </label>
                                    <label style="color:#1e91cf;">Note：<?=lang('product_cbsfhgnote')?></label>
                                </div>
                            </div>
                            <?php endif;?> 
                            <div class="form-group">
                                <label class="col-sm-2 control-label"><?=lang('product_sfzb')?></label>
                                <div class="col-sm-10">
                                    <label class="oms-radio">
                                        <input type="radio" class="inputinWarranty input-no" name="inWarranty_qc" value="0" <?=$ckdInWarranty['0']?> />No
                                    </label>
                                    <?php if($productFirst['inWarranty_qc']==='0' || $productFirst['inWarranty']==='0'):?>
                                        <label class="oms-radio">
                                            <input type="radio" class="inputinWarranty" name="inWarranty_qc" value="1" disabled />Yes
                                        </label>
                                    <?php else: ?>
                                        <label class="oms-radio">
                                            <input type="radio" class="inputinWarranty" name="inWarranty_qc" value="1"  <?=$ckdInWarranty['1']?> />Yes
                                        </label>
                                    <?php endif;?>
                                    <label style="color:#1e91cf;">Note：<?=lang('product_sfzbnote')?></label>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label"><?=lang('product_sfzb')?></label>
                                <div class="col-sm-10">
                                    <label class="oms-radio">
                                        <input type="radio" name="descriptionConsistent" value="No"  <?=$ckdDesCst['No']?>/>No
                                    </label>
                                    <label class="oms-radio">
                                        <input type="radio" name="descriptionConsistent" value="Yes"  <?=$ckdDesCst['Yes']?>/>Yes
                                    </label>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">IMEI</label>
                                <div class="col-sm-10">
                                    <input class="form-control" type="text" name="cb_qc_imei">
                                </div>
                            </div>
                             <div class="form-group">
                                <label class="col-sm-2 control-label"><?=lang('product_wgzk')?></label>
                                <div class="col-sm-10">
                                    <?php foreach ($damageList as $rs):?>
                                    <label class="oms-radio">
                                        <input type="radio" name="physicalAppearance" value="<?=$rs['id']?>" <?=$ckdDamage[$rs['id']]?> /><?=$rs['name_'.$curLang]?>
                                    </label>
                                    <?php endforeach;?>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label"><?=lang('product_sjfj')?></label>
                                <div class="col-sm-10">
                                    <div id="accessoriesDivId">
                                        <?php foreach ($accessoriesList as $rs):?>
                                            <label class="oms-radio">
                                                <input type="checkbox" name="accessories[]" value="<?=$rs['id']?>" <?=$ckdAccessories[$rs['id']]?> /><?=$rs['name_'.$curLang]?>
                                            </label>
                                        <?php endforeach;?>
                                    </div>
                                </div>
                            </div> 
                            <div class="form-group">
                                <label class="col-sm-2 control-label"><?=lang('product_gz')?></label>
                                <div class="col-sm-10">
                                    <div id="faultDivId">
                                        <?php foreach ($faultList as $rs):?>
                                        <label class="oms-radio">
                                            <input type="checkbox" name="fault[]" value="<?=$rs['id']?>" <?=$ckdFault[$rs['id']]?> /><?=$rs['name_'.$curLang]?>
                                        </label>
                                        <?php endforeach;?>
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label"><?=lang('product_cbbz')?></label>
                                <div class="col-sm-10">
                                    <textarea name="csRemark" class="form-control"><?=$productFirst['csRemark']?></textarea>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label"><?=lang('product_bwbzqc')?></label>
                                <div class="col-sm-10">
                                    <textarea name="warranty_remark_qc" class="form-control"><?=$productFirst['warranty_remark_qc']?></textarea>
                                </div>
                            </div>
                            <?php if($isInFreight):?>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">shippingFee</label>
                                    <div class="col-sm-10">
                                        <input class="form-control" id="shippingFeeTextId" name="shippingFeeText" value="<?=$orderFirst['shippingFeeText']?>" onkeyup="this.value=this.value.replace(/[^\d.]/g,'')" />
                                    </div>
                                </div>
                            <?php endif;?>
                            <div class="form-group">
                                    <label class="col-sm-2 control-label"></label>
                                    <div class="col-sm-10">
                                        <input name="id" type="hidden" value="<?=$productFirst['id']?>" />
                                        <input class="btn btn-primary" style="padding:8px 30px" type="submit" value="<?=lang('public_tj')?>" name="submits" />
                                    </div>
                                </div>
                        </form>
                       </div>
                    
                </div>
            </div>
        </div>
    </div>
    <div id="hqDIV" style="display: none">
       <ul class="layer_notice">
           <li>环球易购维修基础信息同步：<span id="hqMsg"><img style="width: 50px;height: 10px;" src="<?=base_url()?>resource/images/loading_h.gif"></span></li>
           <li>&nbsp;</li>
           <li>&nbsp;</li>
           <li style="list-style-type:none;text-align: center;"><input style="width: 80px;;height: 25px;" type="button" value=" OK " onclick="hqUrl()"></li>
       </ul>
    </div>
<script type="application/javascript">
    (function($){
        $(function(){
            /*是否质保选项触发显示质保证明图*/
            function getObjectURL(file) {
              var url = null ; 
              if (window.createObjectURL!=undefined) { // normal
                  url = window.createObjectURL(file) ;
              } else if (window.URL!=undefined) { // firefox
                  url = window.URL.createObjectURL(file) ;
              } else if (window.webkitURL!=undefined) { // google
                  url = window.webkitURL.createObjectURL(file) ;
              }
              return url ;
            }

            $(".inputinWarranty").on("change",function(){
              var inputChecked = $(".input-no").is(':checked');
              if(inputChecked){
                  $('<div class="form-group descriptionConsistent-relation"><div class="form-group descriptionConsistent-relation"><label class="col-sm-2 control-label">保外证明图</label><div><ul class="position-img"> <li> <div class="img-area"> <img src="<?=base_url()?>resource/images/null.png" old-src="<?=base_url()?>resource/images/null.png"> </div> <input type="file" name="warranty_img_1" class="upload-img" accept="image/gif, image/jpeg, image/png"> </li> <li> <div class="img-area"> <img src="<?=base_url()?>resource/images/null.png" old-src="<?=base_url()?>resource/images/null.png"> </div> <input type="file" name="warranty_img_2" class="upload-img" accept="image/gif, image/jpeg, image/png"> </li> <li> <div class="img-area"> <img src="<?=base_url()?>resource/images/null.png" old-src="<?=base_url()?>resource/images/null.png"> </div> <input type="file" name="warranty_img_3" class="upload-img" accept="image/gif, image/jpeg, image/png"></li></ul><div class="clear"></div></div></div>').insertAfter($(this).parent().parent().parent());
                  var str;
                  $('input.upload-img').on("change",function(){
                    str=$(this).val(); 
                    if(str != ""){
                        var oldImgUrl = $(this).siblings('.img-area').find('img').attr("old-src");
                        if(/\.(?:png|PNG|jpg|JPG|gif|PNG)$/.test(str)){
                              var objUrl = getObjectURL(this.files[0]);
                              if (objUrl) {
                                  $(this).siblings('.img-area').find('img').attr("src", objUrl);
                              }
                        }else{ 
                            alert("选择文件错误,图片类型必须是(gif,jpeg,jpg,bmp,png)中的一种");
                            $(this).val("");
                            $(this).siblings('.img-area').find('img').attr("src", oldImgUrl);
                        }
                    }
                  });
              }else{
                  $(".descriptionConsistent-relation").remove();
              }
            });
        });
    })(jQuery);
    
</script>
</div>
